Issue #11720: Kill surviving mutation in RequireThisCheck related to static blocks #11792
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#11720
Hardcoded mutation tested at #11776
Reports with hardcoded mutation (clean):
validateOnlyOverlapping = false
report was not generated with OpenJDK (Out of memory in GitHub actions), though it is very unlikely that it will show any difference, still, if it is required, ping me, and I will generate it locally.This mutation falls in the category:
Rationale:
The condition
definitionToken.getType() == TokenTypes.STATIC_INIT
is same as the conditioncodeBlockDefinition.getType() == TokenTypes.STATIC_INIT
. A variable declared in static block scope, will always have an enclosingCLASS_FRAME
.In the current logic, we skip all frames of type
BLOCK_FRAME
, andFOR_FRAME
to reach theCLASS_FRAME
, if we can't reachCLASS_FRAME
(maybeMETHOD_FRAME
is in between), then we can be assured that there is no static block present.So if there is a static block, we will surely go into the branch
if (variableDeclarationFrame.getType() == FrameType.CLASS_FRAME)
in which we check for the condition-Hence the line can be safely removed, in theory, we would take a hit in TC, as we would make another traversal in
getCodeBlockDefinitionToken(..)
but in reality, there will be no difference, in real case use scenario, 2-3 more iterations.Generating reports again:
Diff Regression config: https://gist.githubusercontent.com/Vyom-Yadav/98dceb63a79f4833e85fff9b2e1464a6/raw/5dc88b466a50335d5759f60c1d041a239f11a5a1/my_checks.xml
Diff Regression projects: https://gist.githubusercontent.com/Vyom-Yadav/91807e6244cff60698d9e33e32ba2d51/raw/ccf3b6b9e053f27b371eb6d1e848d7199dd1f567/projects-to-test-on.properties
Report label: validateOnlyOverlappingFalseWithoutOpenJDK